package com.slg.android.manyanime.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by Thinkpad on 2015/3/12.
 */
public class CartoonGroup {
    //推荐，地区，类型，或者题材

    public CartoonGroup() {
        this.categories = new LinkedList<CartoonCategory>();
    }

    private String group;
    //漫画类型
    private List<CartoonCategory> categories;

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public List<CartoonCategory> getCategories() {
        return categories;
    }

    public void add(CartoonCategory cate) {
        this.categories.add(cate);
    }

    public void parseJson(JSONObject jsonObject) {
        try {
            group = jsonObject.getString("group");
            JSONArray list = jsonObject.getJSONArray("list");
            for (int i = 0; i < list.length(); i++) {
                JSONObject cateJson = list.getJSONObject(i);
                CartoonCategory category = new CartoonCategory();
                category.setCateName(cateJson.getString("name"));
                category.setId(cateJson.getInt("id"));
                category.setPic(cateJson.getString("pic"));

                this.categories.add(category);

            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

}
